package com.sea.app.module.process.controller;

import com.sea.app.common.Entity.Page;
import com.sea.app.common.Entity.http.Response;
import com.sea.app.module.process.controller.param.TaskCompleteRequest;
import com.sea.app.module.process.controller.result.TaskResult;
import com.sea.app.module.process.domain.service.ActivitiTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by 31417 on 2017/5/8.
 */
@RestController
@RequestMapping("/task")
public class TaskController {

    @Autowired
    ActivitiTaskService activitiTaskService;

    /**
     *
     * @param userId 用户ID
     * @param page 分页信息
     * @return
     */
    @RequestMapping("todo")
    public Object todo(@RequestParam("userId") String userId, @RequestParam("role") List<String> roles, Page<TaskResult> page){
        Page<TaskResult> taskPage = activitiTaskService.todo(userId,roles,page);
        return  Response.OK.body(taskPage);
    }
    @RequestMapping("complete")
    public Object complete(TaskCompleteRequest request){
       // org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter
        activitiTaskService.complete(request.getTaskId(),request.getUserId(),request.getComment(),request.getParam());
        return Response.OK.body("操作成功");
    }




}
